<template>
    <view class="container">
		<navbar @clickLeft="toHome" fixed leftIcon="left" :title="'导出私钥'" shadow></navbar>
		
		<view class="content">
				<view class="label">
		            离线保存
		        </view>
		        <view class="text">
		    		请离线保存私钥，切勿保存至邮箱、记事本、聊天工具等
		        </view>
		        <view class="label">
		    		切勿使用网络传输
		    
		        </view>
		        <view class="text">
		    		切勿通过网络工具传播您的私钥，易被黑客窃取造成严重损失，建议使用离线设备扫描二维码导入私钥
		    
		        </view>
		        <view class="label">
		            使用密码工具保存
		        </view>
		        <view class="text">
		            建议您使用密码管理工具保存您的私钥
		        </view>
		        <view class="label">
		            您的私钥：
		        </view>
		        <view class="private-key-area">
		            {{ privateKey }}
		        </view>
				<view class="next-btn" @click="toCopy(privateKey)">
					复制私钥
				</view>
				<view class="next-btn" @click="toHome">
					返回首页
				</view>
		</view>
       
    </view>
</template>
<script>
	import navbar from '@/components/uni-nav-bar'
    import { aboutWallet } from "@/common/businessCommon";

    export default {
        components: {
            navbar
        },
        data() {
            return {
                tabList: [
                   
                ],
                type: 0, // 1正常导出页面 2二维码页面
                privateKey: '',
                codePath: '',
                showCode: false,
            }
        },
        methods: {
            swiperChange(e){
                this.type = e.target.current;
            },
            toCopy(text){
				uni.setClipboardData({
				    data: text,
				    success: function () {
				      uni.showToast({
				        title: '复制私钥成功!',
				        icon: 'none'
				      })
				    }
				});
            },
			toHome(){
				uni.reLaunch({
				    url: '/pages/home/index',
				});
			},
            async getPrivateKey(walletAddress, password){
                let walletInfo = await aboutWallet.getWalletInfo(walletAddress, password);
                this.privateKey = walletInfo.privateKey;
                this.createCode();
            },
        onLoad(option){
            if(!option.address || !option.password){
                throw new Error('缺少地址和密码');
            }
            this.getPrivateKey(option.address, option.password)
        }
    }
}
</script>
<style scoped lang="scss">
    *{
        box-sizing: border-box;
    }
    .container{
        height: 100%;
        display: flex;
        flex-direction: column;
        .transfer-swiper {
            flex: 1;
            .swiper-item {
                height: 100%;
            }
        }

        .content{
            height: 100%;
            overflow: auto;
            padding: 0 36rpx;
            .label{
                color: #333;
                font-size: 30rpx;
                margin-top: 60rpx;
                line-height: 29rpx;
            }
            .text{
                color: #999;
                font-size: 30rpx;
                margin-top: 36rpx;
                 margin-bottom: 36rpx;
            }
            .private-key-area{
                margin-top: 45rpx;
                width: 100%;
                border-radius: 20rpx;
                background: #fff;
                padding: 40rpx 27rpx;
                color: #666;
                font-size: 26rpx;
                word-break: break-all;
                display: flex;
                align-items: center;

            }
            .code-area{
                width: 500rpx;
                height: 500rpx;
                background: #fff;
                margin: 93rpx auto 0;
                display: flex;
                justify-content: center;
                align-items: center;
            }
        }
    }
	.next-btn {
		width: 686rpx;
		height: 90rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #FFFFFF;
		font-size: 32rpx;
		line-height: 32rpx;
		font-weight: 500;
		background-color: #3E2AD1;
		margin-top: 80rpx;
		// margin-bottom: 80rpx;
		border-radius: 20rpx;
	}
</style>
